package tree.structure.rbtree2;

/*
红黑树节点定义
 */
public class RBTreeNode {
    private int key;
    private int nodeColor;
    RBTreeNode left;
    RBTreeNode right;
    RBTreeNode parent;

    private Object v;

    public RBTreeNode(int key) {
        this.key = key;
        // 默认插入节点 红色
        this.nodeColor = NodeColor.RB_NODE_COLOR_RED;
    }

    public int getKey() {
        return key;
    }

    public void setKey(int key) {
        this.key = key;
    }

    public RBTreeNode getLeft() {
        return left;
    }

    public void setLeft(RBTreeNode left) {
        this.left = left;
    }

    public RBTreeNode getRight() {
        return right;
    }

    public void setRight(RBTreeNode right) {
        this.right = right;
    }

    public RBTreeNode getParent() {
        return parent;
    }

    public void setParent(RBTreeNode parent) {
        this.parent = parent;
    }

    public Object getV() {
        return v;
    }

    public void setV(Object v) {
        this.v = v;
    }

    public int getNodeColor() {
        return nodeColor;
    }

    public void setNodeColor(int nodeColor) {
        this.nodeColor = nodeColor;
    }

    public void setRedColor() {
        this.setNodeColor(NodeColor.RB_NODE_COLOR_RED);
    }

    public void setBlackColor() {
        this.setNodeColor(NodeColor.RB_NODE_COLOR_BLACK);
    }

    static class NodeColor {
        public static int RB_NODE_COLOR_RED = 1;
        public static int RB_NODE_COLOR_BLACK = 2;
    }
}
